# Python 2.6.4
# Project Euler, Problem 50
# Copyright 2010 Talha Zaman

from math import sqrt
def isprime(n):
    sn = sqrt(n)+1
    for i in range(2,sn+1):
        if n%i==0: return False
    return True

def sieveprimes(limit):
    sieve = [0 for i in range(0, limit)]
    sieve[0] = sieve[1] = 1
    for i in range(2,limit):
        if sieve[i]: continue
        for j in range(2*i, limit, i):
            sieve[j] += 1
    return [x for x in range(limit) if sieve[x]==0]

lim = 1000000
primes = sieveprimes(lim)
start, end, total, maxcount, maxprime = 0, 0, 0, 0, 0
while start<len(primes):
    while end<len(primes) and total+primes[end]<lim:
        total += primes[end]
        end += 1
    while (end-start>maxcount and not isprime(total)):
        end -= 1
        total -= primes[end]
    if end-start>maxcount:
        maxcount = end-start
        maxprime = total
    total -= primes[start]
    start += 1
print maxcount, maxprime
